package com.hnu.web;

import java.util.List;

import org.apache.struts2.ServletActionContext;

import com.hnu.model.Bookmark;

public class SearchBookmarkBean extends BaseAction {
	private static final long serialVersionUID = -4302649607112152941L;
	private String query;
	private List<Bookmark> bookmarkList;

	public String search() {
		if ((this.query != null) && (!this.query.trim().isEmpty())) {
			String indexPath = ServletActionContext.getRequest().getRealPath(
					"/")
					+ "indexPath";
			bookmarkList = this.servLocator.getBookmarkServ()
					.getSearchBookmark(query, 20, indexPath);
		} else {
			bookmarkList = this.servLocator.getBookmarkServ().getTopNBookmark(
					20);
		}
		return "success";
	}

	public String getQuery() {
		return query;
	}

	public void setQuery(String query) {
		this.query = query;
	}

	public List<Bookmark> getBookmarkList() {
		return bookmarkList;
	}

	public void setBookmarkList(List<Bookmark> bookmarkList) {
		this.bookmarkList = bookmarkList;
	}

}
